<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../../css/reset.css"/>
		<link rel="stylesheet" type="text/css" href="../../css/add.css"/>
	</head>
	<body>
		<div id="app">
			<div class="header">
				<span>添加快递员</span>
			</div>
			<div class="content">
				<table>
					<tr>
						<td class="text-right">姓名</td><td class="content_right"><input  class="input" placeholder="请输入姓名"></td>
					</tr>
					<tr>
						<td class="text-right">手机号码</td><td class="content_right"><input  class="input" placeholder="请输入手机号码"></td>
					</tr>
					<tr>
						<td class="text-right">身份证号码</td><td class="content_right"><input  class="input" placeholder="请输入身份证号码"></td>
					</tr>
					<tr>
						<td class="text-right">密码</td><td class="content_right"><input  class="input" placeholder="请输入密码"></td>
					</tr>
					<tr>
						<td></td><td class="content_right"><span id="submit" class="btn btn-info">立即提交</span> <span class="btn">重置</span> </td>

					</tr>
				</table>
			</div>
		</div>
	</body>
	<script src="../../assets/layui.all.js"></script>
	<script src="/layer/layer.js"></script>
	<script src="/qrcode/jquery2.1.4.js"></script>
	<script>
		$(function () {
			$(document).ready(function () {
				$(".input:eq(0)").blur(function () {
					//获取值
					var name = $(".input:eq(0)").val()
					if(name.match(/.{2,16}/)==null){
						layer.tips("姓名至少是2位哦","#input0",{tipsMore:true,tips:2})
					}else{
						layer.tips("姓名正确",".input:eq(0)",{tipsMore:true,tips:2})
					}

				})
				$(".input:eq(1)").blur(function () {
					//获取值
					var number = $(".input:eq(1)").val()
					if(number.match(/^1[0-9]{10}$/) == null){
						layer.tips("请输入正确的手机号",".input:eq(1)",{tipsMore:true,tips:2})
					}else{
						layer.tips("手机号验证通过",".input:eq(1)",{tipsMore:true,tips:2})
					}
				})
				$(".input:eq(2)").blur(function () {
					//获取值
					var idCard = $(".input:eq(2)").val()
					if(idCard.match(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/) == null){
						layer.tips("身份证号不合法",".input:eq(2)",{tipsMore:true,tips:2})
					}else{
						layer.tips("身份证号验证通过",".input:eq(2)",{tipsMore:true,tips:2})
					}
				})
				$(".input:eq(3)").blur(function () {
					//获取值
					var password = $(".input:eq(3)").val()
					if(password.match(/.{4,18}/) == null){
						layer.tips("请输入4-18位的密码",".input:eq(3)",{tipsMore:true,tips:2})
					}else{
						layer.tips("该密码可以用",".input:eq(3)",{tipsMore:true,tips:2})
					}
				})
			})
		})

	</script>
	<style>
		.layui-layer-content {
			color: #ff5722;
		}
	</style>


<script>
	$(function () {
		$("#submit").click(function () {
			console.log("我执行了")
			var windowId = layer.load();
			var name = $("input:eq(0)").val();
			var phoneNumber = $("input:eq(1)").val();
			var IdCard = $("input:eq(2)").val();
			var passwd = $("input:eq(3)").val();
			if(name.match(/.{2,16}/)==null || phoneNumber.match(/^1[0-9]{10}$/) == null || passwd.match(/.{4,18}/) == null || IdCard.match(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/) == null ){
				layer.close(windowId)
				layer.alert("信息填写有误，请重新填写！",{icon:5})
				return;
			}
			$.post("/courier/insert.do",{
				name : name,
				phoneNumber : phoneNumber,
				IdCard : IdCard,
				passwd : passwd
			},function (result) {
				layer.close(windowId);
				layer.msg(result.result);
				if(result.status==0){
					$("input").val("");
				}
			});
			//return false;
			$(".btn").click(function () {
				$("input").val("");
			})
		})



	})








</script>
</html>
